/*
 * @Author: szx
 * @Date: 2022-02-18 12:35:48
 * @LastEditTime: 2022-02-18 12:41:58
 * @Description:
 * @FilePath: \leetcode\1600-1699\1688\1688.js
 */

/**
 * @param {number} n
 * @return {number}
 */
var numberOfMatches = function (n) {
    let res = 0;
    while (n > 1) {
        const tmp = Math.floor(n / 2);
        if (n & 1) n = 1 + tmp;
        else n = tmp;
        res += tmp;
    }
    return res;
};
console.log(numberOfMatches(14));
